﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Exchange.WebServices.Data;
using Microsoft.Exchange.WebServices.Authentication;

namespace rfins
{
    /// <summary>
    /// Use to send email to a specific address.
    /// The default is set in the global Project settings
    /// </summary>
    public static class mailman
    {
        static Microsoft.Exchange.WebServices.Data.ExchangeService service = Service.ConnectToService(UserData.CreateUserData("dplummer@rhaaia.com"), new TraceListener());
        
        /// <summary>
        /// Call the function with the subject and message you want to send
        /// </summary>
        /// <param name="subject"></param>
        /// <param name="msg"></param>
        /// 

        public static void sendmail(string subject, string msg)
        {
            EmailMessage email = new EmailMessage(service);
            //int count = walmartrealty.Length;
            //ExpandGroupResults walmartrealty = service.ExpandGroup("WalmartRealtyProjects@rhaaia.com");
            //foreach (EmailAddress address in walmartrealty)
            //{
            //    email.ToRecipients.Add(address);
            //}
                   
            email.ToRecipients.Add("dplummer@rhaaia.com");
            email.Subject = subject;
            email.Body = new MessageBody(msg);
            email.Send();            
        }        
    }
}
